<template>
	<view>
		<view style="margin:30rpx 20rpx 60rpx 20rpx;">
			<view style="margin: 20rpx 0;justify-content: space-between;"class="u-flex">
				<u-avatar :src="$url+item.avatar" size="110"></u-avatar>
				<view style="margin-left: 20rpx;flex: 1;">
					<view class="u-flex">
						<view style="font-size: 36rpx;">{{item.authorName}}</view>
						<view style="font-size: 36rpx;">{{item.userName}}</view>
						<text style="margin-left: 20rpx; background-color: #bc9171;color: #fdfbea; 
						border-radius: 0.3em;padding: 5rpx 15rpx;" v-if="item.authorName != null">作者</text>
					</view>
					<view style="color: #B2B2B4;margin-top: 10rpx;">{{item.signature}}</view>
				</view>
				<view>
					<view>
						<view style="background-color: #f7f7f7; padding: 15rpx 30rpx;border-radius: 2em;
						color: #f06d2d; font-weight: bold;" @click="gGuanz(item)" v-if="indexs != 0">
							+&nbsp;关注
						</view>
						<view style="background-color: #f7f7f7; padding: 15rpx 30rpx;border-radius: 2em;
						color: #808080; font-weight: bold;" @click="yGuanz(item)" v-else>
							已关注
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:["item","index"],
		name:"wo-comment",
		data() {
			return {
				indexs:this.index
			};
		},
		methods:{
			yGuanz(e){
				uni.showModal({
					title:"确定不再关注此账号？",
					confirmColor:"#f06d2d",
					confirmText:"不再关注",
					success: (res) => {
						if(res.confirm){
							
							this.indexs = 1
							this.getFollowDelete(e.id)
						}
						
					}
				})
			},
			async getFollowDelete(id){
				const res=await this.$myRequst({
					url:"/follow/delete/"+id,
					method:"DELETE"
				})
				console.log(res)
			},
			async getFollowPost(e){
				const res=await this.$myRequst({
					url:"/follow/post",
					method:"POST",
					data:e
				})
				console.log(res)
			},
			gGuanz(e){
				this.indexs = 0
				this.getFollowPost(e)
			}
		}
	}
</script>

<style>

</style>
